<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<html xmlns:th="http://www.w3.org/1999/html" >
<head>
    <title>802所单点登录</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="images/favicon.ico">
    <!-- Pace -->
<!--    <link rel="stylesheet" th:href="@{~/js/plugins/pace-master/themes/blue/pace-theme-flash.css}">
    <script type="text/javascript" th:src="@{~/js/plugins/pace-master/pace.min.js}"></script>-->
    <!-- Theme style -->
    <!--<link th:href="@{~/css/AdminLTE.css?v=0.0.4}" rel="stylesheet" >-->
    <!-- Bootstrap 3.3.6 -->
    <link th:href="@{css/bootstrap.min.css}" type="text/css" rel="stylesheet" >
    <!-- Font Awesome -->
    <link th:href="@{css/font-awesome.min.css}" type="text/css" rel="stylesheet" >
    <!-- Ionicons -->
    <!--<link th:href="@{~/css/ionicons.min.css}" rel="stylesheet" >-->

    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <!--<link th:href="@{~/css/skins/all-skins.css}" rel="stylesheet" >-->
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script th:src="@{js/plugins/ie9/html5shiv.min.js}"></script>
    <script th:src="@{js/plugins/ie9/respond.min.js}"></script>
    <![endif]-->
    <!--/* Per-page placeholder for additional links */-->
    <link th:href="@{css/login.css}" rel="stylesheet" >
</head>
<body class="login-page" >
<div class="h-full">
    <div class="h-full login-banner-container">
        <div class="h-full login-banner">
            <div class="login-banner-content d-none d-sm-block">
                <div class="login-banner-logo">
                    <i><img src="images/logo1.png"></i>
                </div>
                <h1>八〇二所微服务平台统一登录入口</h1>

            </div>
        </div>
        <div class="login-main">
            <form class="login-form" id="loginForm" >
                <div class="form-logo">
                    <div class="form-caption" >八〇二所微服务平台统一登录入口</div>
                    <div><img src="images/logo1-dark.png"></div>
                    <!--<div class="i-logo"></div>-->

                </div>
                <h4 class="d-none d-sm-block">
                    <!--<i class="fa fa-user"></i>-->
                    [[${clientdes}]]--用户登录
                </h4>
                <div class="form-group">
                    <label class="sr-only" for="username">账户类型</label>
                    <select type="text" class="form-control" id="logintype" name="logintype" >
                        <option value="macross">账户类型-系统默认</option>
                    </select>
                </div>
                <div class="form-group">
                    <label class="sr-only" for="username">用户名</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
                </div>
                <div class="form-group">
                    <label class="sr-only" for="password">密码</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
                </div>
                <div class="form-group" style="display: none;">
                    <label class="sr-only" for="password">验证码</label>
                    <div class="input-group">
                        <input type="text" class="form-control" id="verifyCode" name="verifyCode" placeholder="请输入验证码">
                        <span class="input-group-addon n-p" >
                            <img id="imgCode" src="captcha" width="100" onclick = "this.src='captcha?d='+new Date()*1"/>
                        </span>
                    </div>
                </div>
                <!--<div class="form-group clearfix">
                    <div class="checkbox-custom checkbox-inline checkbox-primary float-left">
                        <input type="checkbox" id="rememberMe" name="rememberMe">
                        <label for="remember">自动登录</label>
                    </div>
                    <a class="float-right collapsed" data-toggle="collapse" href="#forgetPassword" aria-expanded="false" aria-controls="forgetPassword">
                        忘记密码了？
                    </a>
                </div>
                <div class="collapse" id="forgetPassword" aria-expanded="true">
                    <div class="alert alert-warning alert-dismissible" role="alert">
                        请联系管理员重置密码。
                    </div>
                </div>-->
                <button id="btnLogin" class="btn btn-primary btn-block">登 录</button>
            </form>
        </div>
    </div>

</div>
<!--<script th:src="@{~/js/CFInstall.min.js}">
    // You may want to place these lines inside an onload handler
    //检测chormeframe 是否已经安装
    CFInstall.check({
        mode: "overlay",
        url:"/kits/chrome.msi",
        node: "prompt",
        destination: "testChrome.jsp"
    });
</script>-->
<script th:src="@{js/jquery-2.2.3.min.js}"></script>
<script th:src="@{js/plugins/layer/layer.js}"></script>
<script th:src="@{js/plugins/validate/jquery.validate.min.js}"></script>
<script th:src="@{js/plugins/validate/jquery.validate.ext.js}"></script>
<script th:src="@{js/plugins/validate/messages_zh.min.js}"></script>
<script th:src="@{js/jquery.base64.js}"></script>
<script th:src="@{js/util.js}"></script>
<script type="text/javascript">
    $(document).ready(function () {

        var e = "<i class='fa fa-times-circle'></i> ";
        $("#loginForm").validate({
            rules: {
                username: {
                    required: !0,
                    minlength: 4
                },
                password: {
                    required: !0,
                    minlength: 6
                }
                /*,verifyCode:{
                    required:true,
                    minlength: 4,
                    remote:{
                        type:"POST",
                        url:"captcha", //请求地址
                        data:{
                            verifyCode:function(){ return $("#verifyCode").val(); }
                        }
                    }
                }*/

            },
            errorPlacement: function (error, element) {
                if (element.next().hasClass("input-group-addon")&&element.parent().hasClass("input-group")){
                    error.appendTo(element.parent().parent());
                }else {
                    error.insertAfter(element);
                }
            },
            messages: {
                username:e+ "请输入4位及以上的用户名",
                password:e+ "请输入6位及以上的密码",
                verifyCode:e+"请输入4位正确的验证码"
            },
            submitHandler:function(form){
                var loginBtn =$("#btnLogin");
                var pwd="";
                try {
                    uid = encodeBase64($("#username").val());
                    pwd = encodeBase64($("#password").val());
                }
                catch(e)
                {
                    layer.alert("用户名和密码请勿输入中文",{
                        icon: 2
                    });
                    return false;
                }
                $.ljPost(
                    {
                        url:"ssologin",
                        isShowLoader:false,
                        //header:"eyJ0eXBlIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiJhd2ZzZXJ2ZXIiLCAidWlkIjoibGlqaWEiLCJwdCI6MTU1MjQ0NzA4ODgzNH0.RZ2isE4Gc2a-DGfhK9Fwmo4asP8ZJDe2PMWgNm1IRKU",
                        param:"uid="+uid+"&type="+$("#logintype").val()+"&pwd="+pwd+"&clientid=[[${clientid}]]",
                        onSuccess:function (resp,textStatus,resObj) {
                            if(resp.result)
                            {
                                //alert(JSON.stringify(resp.data));
                                //alert("[[${clientip}]]");
                                var clientip = "[[${clientip}]]";
                                //var end = clientip.split(".")[3];
                                var redirecturl = resp.data.entryuri;
                                if(redirecturl!=null)
                                {
                                    window.location = redirecturl+"?id=[[${clientid}]]&at="+resp.data.access_token+"&tt="+resp.data.token_type+"&rt="+resp.data.refresh_token+"&ei="+resp.data.expires_in;
                                }
                                else {
                                    loginBtn.text("登 录");
                                    loginBtn.removeAttrs("disabled");
                                    $("#imgCode").trigger("click");
                                    layer.alert("客户端未在平台中注册回调地址", {
                                        icon: 2
                                    });
                                }

                            }
                            else
                            {
                                layer.alert(resp.message, {
                                    icon: 2
                                });
                                loginBtn.text("登 录");
                                loginBtn.removeAttrs("disabled");
                                $("#imgCode").trigger("click");
                            }
                        },
                        onError:function(resp){
                            loginBtn.text("登 录");
                            loginBtn.removeAttrs("disabled");
                            $("#imgCode").trigger("click");
                            layer.alert("用户名或密码错误", {
                                icon: 2
                            });
                        },
                        onComplete:function () {

                        }
                    }
                );
                loginBtn.text("验证中...");
                loginBtn.attr("disabled","disabled");
                return false;

            }
        });

    });

</script>

</body>
</html>